/**
 * Created by wujo5 on 1/19/2018.
 */
var express = require('express');
var _ = require('lodash');
var emsMonitorCtrl = require('../controller/emsMonitorController');
var router = express.Router();


router.get('/getMonitorDests', function (req, res) {
  emsMonitorCtrl.getTestCaseList(function (datas) {
    var destList = [];
    datas.forEach(function (testCase) {
      if (!_.isEmpty(testCase.outQueue) && !destList.includes(testCase.outQueue)) {
        destList.push(testCase.outQueue);
      }
    }, this);
    res.send(destList);
  }, function (err) {
    res.send(err);
  })
});

router.post('/saveEmsMessage', function (req, res) {
  let dest = req.body.dest[0], msg = req.body.message[0];
  emsMonitorCtrl.saveEmsMsg(dest,msg, function (data) {
    res.send(data);
  }, function (err) {
    res.send(err);
  });
});


router.post('/getEmsMonitorByBizKeyAndQueueName', emsMonitorCtrl.getEmsMonitorByBizKeyAndQueueName);
router.get('/clearAllEmsMonitorResult', emsMonitorCtrl.clearAllEmsMonitorResult);

module.exports = router;
